#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.

# FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
# WORKDIR /app
# RUN apt-get update && apt-get -y install xvfb gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgbm1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget unzip procps --no-install-recommends && rm -rf /var/lib/apt/lists/*
# COPY WebAgent/Chrome Chrome
# COPY WebAgent/ChromeHeadlessShell ChromeHeadlessShell
# EXPOSE 80
# EXPOSE 443

ARG NAMESPACE

FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["WebAgent/WebAgent.csproj", "WebAgent/"]
RUN dotnet restore "./WebAgent/WebAgent.csproj" -s http://10.0.1.62:8081/nexus/repository/Gasgoo-dev/ -s http://10.0.1.62:8081/nexus/repository/nuget-hosted/ -s https://api.nuget.org/v3/index.json
COPY . .
WORKDIR "/src/WebAgent"
RUN chmod -R 755 /src
RUN dotnet build "./WebAgent.csproj" -c $BUILD_CONFIGURATION -o /app/build
RUN chmod -R 755 /app


FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./WebAgent.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
RUN apt-get update && apt-get -y install xvfb gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgbm1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget unzip procps --no-install-recommends && rm -rf /var/lib/apt/lists/*
COPY --from=publish /app/publish .

RUN rm -f /etc/localtime \
&& ln -sv /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
&& echo "Asia/Shanghai" > /etc/timezone
EXPOSE 5000
ENTRYPOINT ["dotnet", "WebAgent.dll"]
